<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ include file="/wesite/view/common/base.jsp" %>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>商品详情</title>
    <%@ include file="/wesite/view/common/common.jsp" %>
    <link rel="stylesheet" type="text/css" href="${webctx}/css/aui-slide.css"/>
    <script type="text/javascript" src="${webctx}/script/aui-tab.js"></script>
    <script type="text/javascript" src="${webctx}/script/aui-slide.js"></script>
    <style>
        .shop-deteil img {
            display: block;
        }

        .shop-deteil li {
            color: #666;
        }
    </style>
</head>
<body>
<input name="priceid" value="${bean.id }" type="hidden">
<div class="product-detail marketing-info">
    <c:choose>
        <c:when test="${!isSale}">
            <div class="unshelve">
                <div class="cartoon">
                    <img src="${webctx}/images/cartoon-unshelve.png">
                    <p>很抱歉，您查看的商品不存在，可能已下架或者被转移。</p>
                </div>
                <div class="explain">
                    <h3>您可以：</h3>
                    <p>① 该商品可能已经下架，您可以联系客服，400-805-5522。</p>
                    <p>② 在顶部搜索框重新输入关键词搜索</p>
                    <p>③ 选择下方您可能喜欢的商品</p>
                </div>
            </div>
        </c:when>
        <c:otherwise>
            <!-- banner切换 -->
            <div class="slide-p" id="aui-slide">
                <div class="aui-slide-wrap">
                    <c:choose>
                        <c:when test="${fn:length(bean.photos)==0}">
                            <div class="aui-slide-node">
                                <a href="#">
                                    <img src="${webctx}/images/noimg.jpg" width="380" height="380"/>
                                </a>
                            </div>
                        </c:when>
                        <c:otherwise>
                            <c:forEach items="${bean.photos}" var="photo">
                                <div class="aui-slide-node">
                                    <a href="#">
                                        <img src="<%=getRandomFileserver()%>${photo.filepath}" width="380"
                                             height="380"
                                             onerror="this.src='${webctx}/images/noimg.jpg'"/>
                                    </a>
                                </div>
                            </c:forEach>
                        </c:otherwise>
                    </c:choose>
                </div>
                <div class="aui-slide-page-wrap"><!--分页容器--></div>
            </div>

            <c:if test="${not empty wePromotions && not empty wePromotions.flash_sale}">
                <div class="seckill-time">
                    <c:choose>
                        <c:when test="${wePromotions.flash_sale.countDown==1}">
                            <p endtime="${wePromotions.flash_sale.surplusSeconds}" class="endtime drug-overtime"></p>
                        </c:when>
                        <c:otherwise>
                            <p class="endtime drug-overtime">活动火热进行中</p>
                        </c:otherwise>
                    </c:choose>
                </div>
            </c:if>

            <div class="product-name conbox">
                <h3>${bean.name }</h3>
                <div class="product-text fl">
                    <p>厂家：${bean.manufacturers}</p>
                    <p>规格：${bean.specification}</p>
                </div>
                <div class="count">
                    <span>数量：</span>
                    <div class="count-box">
                        <i class="sy_minus" onclick="lessenamount()">-</i>
                        <input class="num focus-auto-select" name="amount" onchange="inputAmount(this)" type="number"
                        <c:choose>
                        <c:when test="${not empty wePromotions && not empty wePromotions.flash_sale && not empty wePromotions.flash_sale.time}">
                               value="${wePromotions.flash_sale.times<=0?0:1}"
                               maxnum="${wePromotions.flash_sale.times}"
                        </c:when>
                        <c:otherwise>
                               value="${bean.amount<=0?0:1}"
                               maxnum="${bean.amount}"
                        </c:otherwise>
                        </c:choose>
                        ><i class="sy_plus" onclick="addamount()">+</i>
                    </div>
                </div>
            </div>
            <c:choose>
                <c:when test="${bean.control}">
                    <div class="sec-price div-list">
                        <p>采购价：<em>不在本区域销售</em></p>
                    </div>
                </c:when>
                <c:when test="${not empty wePromotions && not empty wePromotions.flash_sale}">
                    <div class="sec-price div-list">
                        <p>秒杀价：<em>¥${wePromotions.flash_sale.price}</em><span>￥${bean.price}</span></p>
                    </div>
                </c:when>
                <c:otherwise>
                    <div class="sec-price div-list">
                        <p>采购价：
                            <c:choose>
                                <c:when test="${islogin && isuserauth }">
                                    <em>¥${bean.price}</em>
                                </c:when>
                                <c:when test="${!islogin }">
                                    <em class="b">登录可见</em>
                                </c:when>
                                <c:when test="${!isuserauth }">
                                    <em class="b">审核通过可见</em>
                                </c:when>
                            </c:choose>
                        </p>
                    </div>
                </c:otherwise>
            </c:choose>

            <!-- 优惠券 -->
            <c:if test="${not empty coupons}">
            <div class="give-coupon div-list">
                <span>领券:
                    <c:forEach items="${coupons}" var="coupon">
                    <em class="sp-em">￥${coupon.offerMoney}</em>
                    </c:forEach>
                </span>
                <a class="give-btn" href="javascript:;">点击领券</a>
            </div>
            </c:if>


            <!-- 促销信息 -->
            <c:if test="${not empty wePromotions}">
                <div class="sales-act">
                    <span class="salse-tit">促销：</span>
                    <div class="sales-text sales-wid fl">
                        <c:if test="${not empty wePromotions.flash_sale}">
                            <div class="sal-item">
                                <span class="text-msg">限制</span>
                                <c:choose>
                                    <c:when test="${not empty wePromotions.flash_sale.time}">每人限购${wePromotions.flash_sale.time}件</c:when>
                                    <c:otherwise>无限制</c:otherwise>
                                </c:choose>
                            </div>
                        </c:if>
                        <c:if test="${not empty wePromotions.buy_send}">
                            <div class="sal-item">
                                <span class="text-msg">买送</span>
                                买${wePromotions.buy_send.buyNumber}${bean.unit}，送${wePromotions.buy_send.sendNumber}${bean.unit};
                                <c:if test="${not empty wePromotions.money_off.description}">
                                    （${wePromotions.money_off.description}）
                                </c:if>
                            </div>
                        </c:if>
                        <c:if test="${not empty wePromotions.money_off}">
                            <div class="sal-item sal-item-ov">
                                <span class="text-msg">满减</span>
                                <c:forEach items="${wePromotions.money_off.items}" var="item">
                                    <c:choose>
                                        <c:when test="${not empty item.discountMoney}">
                                            满${item.offMoney}元减${item.discountMoney};
                                        </c:when>
                                        <c:otherwise>
                                            满${item.offMoney}打<fmt:formatNumber value="${item.discountRate}"
                                                                                pattern="#0.##"/> 折;
                                        </c:otherwise>
                                    </c:choose>
                                </c:forEach>
                                <c:if test="${not empty wePromotions.money_off.description}">
                                    （${wePromotions.money_off.description}）
                                </c:if>
                            </div>
                        </c:if>
                        <c:if test="${not empty wePromotions.purchase_gift}">
                            <div class="sal-item">
                                <span class="text-msg fl">满赠</span>
                                <ul class="fl">
                                    <c:forEach items="${wePromotions.purchase_gift.items}" var="item">
                                        <li>
                                            <c:choose>
                                                <c:when test="${not empty item.minMoney}">
                                                    满${item.minMoney}元&nbsp;赠
                                                </c:when>
                                                <c:otherwise>
                                                    满${item.minNumber}${bean.unit}&nbsp;赠
                                                </c:otherwise>
                                            </c:choose>
                                            <c:forEach items="${item.gifts}" var="gift">
                                                ${gift.name} X${gift.unit}&nbsp;
                                            </c:forEach>
                                        </li>
                                    </c:forEach>
                                </ul>
                            </div>
                        </c:if>
                    </div>
                    <a class="salse-more" href="javascript:;">
                        <span></span>
                        <span></span>
                        <span></span>
                    </a>
                    <div class="aui-clearfix"></div>

                    <!-- 更多促销信息弹窗 -->
                    <div class="sale-more-con" style="display: none;">
                        <a class="close" href="javascript:;"></a>
                        <div class="more-con-tit">促销</div>
                        <div class="sales-text more-con-list">
                            <c:if test="${not empty wePromotions.flash_sale}">
                                <div class="sal-item sal-item-ov">
                                    <p>
                                        <span class="text-msg">限制</span>
                                        <c:choose>
                                            <c:when test="${not empty wePromotions.flash_sale.time}">每人限购${wePromotions.flash_sale.time}件</c:when>
                                            <c:otherwise>无限制</c:otherwise>
                                        </c:choose>
                                    </p>
                                </div>
                            </c:if>
                            <c:if test="${not empty wePromotions.buy_send}">
                                <div class="sal-item sal-item-ov">
                                    <p>
                                        <span class="text-msg">买送</span>
                                        买${wePromotions.buy_send.buyNumber}件，送${wePromotions.buy_send.sendNumber}件;
                                        <c:if test="${not empty wePromotions.money_off.description}">
                                            （${wePromotions.money_off.description}）
                                        </c:if>
                                    </p>
                                </div>
                            </c:if>
                            <c:if test="${not empty wePromotions.money_off}">
                                <div class="sal-item">
                                    <p>
                                        <span class="text-msg">满减</span>
                                        <span class="txt">
                                            <c:forEach items="${wePromotions.money_off.items}" var="item">
                                                <c:choose>
                                                    <c:when test="${not empty item.discountMoney}">
                                                        满${item.offMoney}元减${item.discountMoney};
                                                    </c:when>
                                                    <c:otherwise>
                                                        满${item.offMoney}打<fmt:formatNumber value="${item.discountRate}"
                                                                                            pattern="#0.##"/> 折;
                                                    </c:otherwise>
                                                </c:choose>
                                            </c:forEach>
                                        <c:if test="${not empty wePromotions.money_off.description}">
                                            （${wePromotions.money_off.description}）
                                        </c:if>
                                        </span>
                                    </p>
                                </div>
                            </c:if>
                            <c:if test="${not empty wePromotions.purchase_gift}">
                                <div class="sal-item">
                                    <span class="text-msg fl">满赠</span>
                                    <ul class="fl">
                                        <c:forEach items="${wePromotions.purchase_gift.items}" var="item">
                                            <li>
                                                <c:choose>
                                                    <c:when test="${not empty item.minMoney}">
                                                        满${item.minMoney}元送,赠完即止
                                                    </c:when>
                                                    <c:otherwise>
                                                        满${item.minNumber}件送,赠完即止
                                                    </c:otherwise>
                                                </c:choose>
                                                <c:if test="${not empty wePromotions.money_off.description}">
                                                    （${wePromotions.money_off.description}）
                                                </c:if>
                                                <c:forEach items="${item.gifts}" var="gift">
                                                    <a href="${ctx}/we/product/${gift.productid}"
                                                       class="p-txt">${gift.name}X${gift.unit}</a>
                                                </c:forEach>
                                            </li>
                                        </c:forEach>
                                    </ul>
                                    <div class="cl"></div>
                                </div>
                            </c:if>
                        </div>
                    </div>
                </div>
            </c:if>

            <div class="intro mt20">
                <div class="aui-tab" id="tab">
                    <div class="aui-tab-item aui-active"><span>商品详情</span></div>
                    <div class="aui-tab-item"><span>售后保障</span></div>
                </div>
                <div class="tab-content">
                    <div class="tab-ct-item shop-deteil" style="display:block; background-color: #fff">
                            ${bean.details }
                    </div>
                    <div class="tab-ct-item after-buy">
                        <div>
                            <h3>[ 药品验收 ] ：</h3>
                            <p style="line-height: 1.8em;">
                                您在收到商品时，签字确认前须对商品进行开箱检验，核实药品数量及规格是否相符、药品包装是否完好、是否与您购买的药品一致。如果您验货时发现药品包装破损、药品短缺或错误、药品存在表面质量问题、药品剩余保质期少于6个月（活动、促销、赠送或事先有明确的除外）等其中一项，您有权拒绝签字，并与业务员沟通退换货。
                                如您选择的是第三方物流配送，请签字后在配送人员面前进行上述条件的验收，如有不符合要求的，应让送货人员出具货物损毁证明，同时拨打我们服务电话400-805-5522进行联系确认，我们会尽快安排退换货。</p>
                        </div>
                        <div>
                            <h3 style="margin-top: 20px;">[ 退换政策 ] ：</h3>
                            <p style="line-height: 1.8em;">
                                您收到商品的7天内，符合下列药品退换货要求的，可以申请退换货。拨打巨达药网服务热线（400-805-5522）或跟当地业务员进行沟通，巨达药网将尽快安排处理。</p>
                            <p style="line-height: 1.8em;">1、由巨达药网原因失误造成发货错误或延迟送货的；</p>
                            <p style="line-height: 1.8em;">2、由于产品本身存在质量问题，经质量管理部门检验，确属质量问题的；</p>
                            <p style="line-height: 1.8em;">3、国家权威管理部门发布公告的产品（如停售、收回等）；</p>
                            <p style="line-height: 1.8em;">4、收到商品时，部分商品破损、溢漏、配件缺失，业务人员或快递人员当场确认的。</p>
                            <p style="line-height: 1.8em;">对不具备下列条件的，巨达药网将不予退换货：</p>
                            <p style="line-height: 1.8em;">1、在退换货之前您未与巨达药网客服或者当地业务员取得联系；</p>
                            <p style="line-height: 1.8em;">2、非质量问题且商品包装已被拆封；</p>
                            <p style="line-height: 1.8em;">3、因人为的非正确使用和储藏不当而出现质量问题；</p>
                            <p style="line-height: 1.8em;">4、退回商品外包装或其他商品附属物不完整或有毁损；</p>
                            <p style="line-height: 1.8em;">5、所需退货商品的批号、型号、规格与售出时不符；</p>
                            <p style="line-height: 1.8em;">6、商品并非巨达药网提供。</p>
                        </div>
                    </div>
                </div>
            </div>
        </c:otherwise>
    </c:choose>
    <!-- 猜你喜欢 -->
    <div class="product-box mt20">
        <div class="hd"><h2>猜你喜欢</h2></div>
        <div class="content shopclass">
            <ul id="maylike">

            </ul>
        </div>
    </div>
</div>
<div class="cl"></div>
<c:if test="${isSale}">
    <div class="h98"></div>
    <div class="product-detail-bottom">
        <div class="fl">
            <ul>
                <li class="home">
                    <a href="${ctx}/we/index">
                        <i class="ico"></i>
                        <span>首页</span>
                    </a>
                </li>
                <li class="car">
                    <a href="${ctx}/we/weshopcart">
                        <i class="ico"></i>
                        <span>购物车</span>
                        <i class="num _bottomCartNum"></i>
                    </a>
                </li>
                <li class="collect">
                    <a href="javascript:void(0);">
                        <c:if test="${!bean.favorite }">
                            <span onclick="toggleOften(this)" class="join-list gray">
                                <i class="ico"></i>
                                <span>收藏</span>
                            </span>
                        </c:if>
                        <c:if test="${bean.favorite }">
                            <span onclick="toggleOften(this)" class="join-list ico-keep-blue">
                                <i class="ico"></i>
                                <span>已收藏</span>
                            </span>
                        </c:if>

                    </a>
                </li>
            </ul>
        </div>
        <div class="btn fr">
            <c:choose>
                <c:when test="${!bean.control && bean.amount > 0 && bean.price > 0}">
                    <a href="javascript:addtocart();">
                        <span class="join-car"><i>加购物车</i></span>
                    </a>
                </c:when>
                <c:otherwise>
                    <a href="javascript:void(0);">
                        <span class="grizzle"><i>加购物车</i></span>
                    </a>
                </c:otherwise>
            </c:choose>
        </div>
    </div>
</c:if>


<!-- 遮罩层 -->
<div class="mask"></div>
<%@ include file="/wesite/view/common/coupon-popup.jsp" %>
</body>
<script src="${webctx}/script/productinfo.js"></script>
<script src="${webctx}/script/location.js"></script>
<script type="text/javascript">



    $(".salse-more").click(function () {
        $(".mask").fadeIn("slow");//遮罩层
        $(".sale-more-con").fadeIn("slow");
    });
    $(".give-btn").click(function () {
        $(".mask").fadeIn("slow");//遮罩层
        $(".coupon-popup-in").fadeIn("slow");
    });
    $(".close").click(function () {
        $(".mask").fadeOut("slow"); //遮罩层
        $(".sale-more-con").fadeOut("slow");
        $(".coupon-popup-in").fadeOut("slow");
    });
    $(".mask").click(function () {
        $(".mask").fadeOut("slow"); //遮罩层
        $(".sale-more-con").fadeOut("slow");
        $(".coupon-popup-in").fadeOut("slow");
    });

    function showloginpage(tourl) {
        var curUrl = "";
        if (tourl) curUrl = tourl;
        else curUrl = window.location.href;
        sessionStorage.setItem("_curUrl_", curUrl);
        window.location.href = loginUrl;
    }

    /*猜你喜欢*/
    function loadMaylike(size, fun, pno) {
        var priceid = getBrowsepriceid();
        var url = apiroot + '/product/maylike?priceid=' + priceid + "&pagesize=" + size;
        if (pno) url += "&pageno=" + pno;
        $w.httpRequest({
            url: url,
            data: {},
            ok: function (ret) {
                fun(ret.Data);
            }
        })
    }

    //添加收藏
    function productfavorite() {
        var action = 0;
        if ($(".product-detail-bottom .fl ul li.collect i.ico").hasClass("ico-blue")) {
            action = 1;
        }
        if ($w.checkLogin(true, ctx + "/we/product/" + $("[name='priceid']").val())) {
            $w.httpRequest({
                url: apiroot + '/we/favorite/' + $("[name='priceid']").val(),
                method: 'post',
                data: {"action": action},
                ok: function () {
                    if (action) {
                        $(".product-detail-bottom .fl ul li.collect i.ico").removeClass("ico-blue");
                        new auiToast().success({
                            title: "取消收藏成功",
                            duration: 300
                        });
                    } else {
                        $(".product-detail-bottom .fl ul li.collect i.ico").addClass("ico-blue");
                        new auiToast().success({
                            title: "收藏成功",
                            duration: 300
                        });
                    }
                },
                fail: function (ret) {
                    if (ret.MsgCode) {
                        new auiToast().fail({
                            title: ret.MsgDesc,
                            duration: 300
                        });
                    } else {
                        new auiToast().fail({
                            title: "收藏失败",
                            duration: 300
                        });
                    }
                }
            })
        }
    }

    //添加购物车
    var cartSubmit = true;
    function addtocart() {
        if (cartSubmit && $w.checkLogin(true, ctx + "/we/product/" + $("[name='priceid']").val())) {
            cartSubmit = false;
            var product = $("[name='priceid']").val() + "_" + $("[name='amount']").val();
            var productAttr = [];
            productAttr.push(product);
            $w.httpRequest({
                url: "${ctx}/we/home/addToCart",
                data: {"idsAmounts": productAttr},
                ok: function () {
                    $w.httpRequest({
                        url: "${ctx}/order/getCartNum",
                        method: "get",
                        ok: function (ret) {
                            if (ret.Data) {
                                $("._bottomCartNum").text(ret.Data);
                            } else {
                                $("._bottomCartNum").removeClass("num");
                            }
                        }
                    })
                    new auiToast().success({
                        title: "加入购物车成功",
                        duration: 800
                    })
                },
                fail: function (ret) {
                    new auiToast().fail({
                        title: "加入购物车失败",
                        duration: 800
                    });
                },
                all: function () {
                    cartSubmit = true;
                }
            })
        }

    }
    apiready = function () {
        api.parseTapmode();
    }

    /*滚动图*/
    var slide = new auiSlide({
        container: document.getElementById("aui-slide"),
        "speed": 500,
        "autoPlay": 3000, //自动播放
        "pageShow": true,
        "pageStyle": 'dot',
        "loop": true,
        'dotPosition': 'center',
    })
    /*切换*/
    var tab = new auiTab({
        element: document.getElementById("tab"),
    });

    $('.aui-tab-item').click(function () {
        var index1 = $(this).index();
        $('.tab-content .tab-ct-item').eq(index1).show().siblings().hide()
    })

    $(function () {
        var flashSaleTimeInterval = window.setInterval(function () {
            var drugOvertimeItems = $(".drug-overtime[endTime]");
            if (drugOvertimeItems.length > 0) {
                drugOvertimeItems.each(function () {
                    var endTime = $(this).attr("endTime");
                    if (endTime > 0) {
                        var h = parseInt(endTime / (60 * 60));//小时
                        var m = parseInt(endTime / 60 % 60);//分钟
                        var s = parseInt(endTime % 60); //秒
                        $(this).html("秒杀倒计时：<span>" + h + "</span> 时 <span>" + m + "</span> 分 <span>" + s + "</span> 秒");
                        endTime--;
                        $(this).attr("endTime", endTime);
                    } else {
                        $(this).html("活动已截止");
                        $(this).removeAttr("endTime");
                    }
                });
            } else {
                window.clearInterval(flashSaleTimeInterval);
            }
        }, 1000);

        $w.httpRequest({
            url: "${ctx}/order/getCartNum",
            method: "get",
            ok: function (ret) {
                if (ret.Data) {
                    $("._bottomCartNum").text(ret.Data);
                } else {
                    $("._bottomCartNum").removeClass("num");
                }
            }
        })
    })
</script>
</html>